//
//  ZHCustomTabBar.swift
//  999999新浪微博
//
//  Created by 陈华 on 15/12/16.
//  Copyright © 2015年 华锐. All rights reserved.
//

import UIKit

class ZHCustomTabBar: UITabBar {
    let number: CGFloat = 5

    override func layoutSubviews() {
        super.layoutSubviews()
        
        let width = self.bounds.width / number
        var i = 0
        for itme in subviews{//遍历tabBar所有子控件
            
            if itme is UIControl{//判断是否是item
                
                if i == 2{
                   let bnt = UIButton(type: UIButtonType.Custom)
                    bnt.frame = CGRect(x: width * CGFloat(i), y: 0, width: width, height: self.bounds.height)
                    bnt.setBackgroundImage(UIImage(named: "tabbar_compose_button"), forState: UIControlState.Normal)
                    bnt.setBackgroundImage(UIImage(named: "tabbar_compose_button_highlighted"), forState: UIControlState.Normal)
                    bnt.setImage(UIImage(named: "tabbar_compose_icon_add"), forState: UIControlState.Normal)
                    bnt.setImage(UIImage(named: "tabbar_compose_icon_add_highlighted"), forState: UIControlState.Highlighted)
                    self.addSubview(bnt)
                    i++
                }
                let itmeX =  width * CGFloat(i)
                itme.frame = CGRect(x: itmeX, y: 0, width: width, height: self.bounds.height)
                i++
            }
        }
    }
}























